﻿using System.Runtime.CompilerServices;

namespace Syntax
{
    /// <summary>
    /// C# 10.0语法
    /// </summary>
    public class Syntax10
    {
        public void lambda()
        {
            Func<string, int> parse = (string s) => int.Parse(s);

            var parse1 = (string s) => int.Parse(s);

            Func<int> read = Console.Read;
            Action<string> write = Console.Write;

            int x2;
            int y2;
            (x2, y2) = (0, 1);       // Works in C# 9
            (var x, var y) = (0, 1); // Works in C# 9
            (x2, var y3) = (0, 1);   // Works in C# 10 onwards
        }
        void MyMethod(object value)
        {
            ArgumentNullException.ThrowIfNull(value);
        }


        internal static void CheckExpression(bool condition,
                [CallerArgumentExpression("condition")] string? message = null)
        {
            Console.WriteLine($"Condition: {message}");
        }
    }
}
